<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="${dir}.dao.${table.name}Dao">

    <resultMap type="${dir}.entity.${table.name}"  id="${table.name}map">
        <#list table.colums as c>
            <#if c.status == 1>
                <id column="${c.cname}" property="${c.name}"></id>
            <#else>
                <result column="${c.cname}" property="${c.name}"></result>
            </#if>
        </#list>
    </resultMap>
    <select id="selectOne" resultMap="${table.name}map">
        select * from ${table.name!} where ${table.pkColumns.cname} = <#noparse>#{id}</#noparse>
    </select>

    <select id="selectAll" resultMap="${table.name}map">
        select * from ${table.name!}
    </select>

    <insert id="add">
        insert into ${table.name!}(<#list table.colums as c>${c.cname}<#if c_index<table.colums?size-1>,</#if></#list>) values(<#list table.colums as c><#noparse>#{</#noparse>${c.name}}<#if c_index<table.colums?size-1>,</#if></#list>)
    </insert>

    <update id="update">
        update ${table.name!} set <#list table.colums as c><#if c.status!=1>${c.cname}=<#noparse>#{</#noparse>${c.name}}<#if c_index<table.colums?size-1>,</#if></#if></#list> where where ${table.pkColumns.cname} = <#noparse>#{id}</#noparse>
    </update>

    <delete id="delete">
        delete from ${table.name!} where ${table.pkColumns.cname} = <#noparse>#{id}</#noparse>
    </delete>
</mapper>